package cate.common.table.res.godstreet;

import cate.common.table.ESheet;
import cate.common.table.d.GDGodStreet;
import easy.java.dev.note.NoteClass;

import java.util.*;

@NoteClass(value = "食神之路-任务")
public class GodStreetTaskSheet extends ESheet<GodStreetTaskRow> {

    @Override
    public String getSheetName() {
        return "食神之路";
    }

    @Override
    protected void onRowCreated(GodStreetTaskRow row) {
        super.onRowCreated(row);

    }

    /**
     * 根据任务Id找等级阶段ID
     *
     * @param taskId 任务id
     * @return 等级阶段
     */
    public int taskToStage(int taskId) {
        for (GodStreetTaskRow row : getList()) {
            if (row.id == taskId)
                return row.stageId;
        }
        return GDGodStreet.UNAVAILABLE_INTEGER_VALUE;
    }

    /**
     * 根据等级阶段获取TaskList
     *
     * @return
     */
    public List<Integer> getTaskListByStage(int stageId) {
        List<Integer> tasks = new ArrayList<>();
        for (GodStreetTaskRow row : getList()) {
            if (row.stageId == stageId)
                tasks.add(row.id);
        }
        return tasks;
    }
}
